import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2023-02-23
 * Time: 23:07
 */
class Person{
    String id;

    public Person(String id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return Objects.equals(id, person.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
public class HashBuckTest {

    public static void main(String[] args) {
        Person person1 = new Person("123");
        Person person2 = new Person("234");
        Person person3 = new Person("123");
        //hashCode的地址将引用对象转为hash值
        System.out.println(person1.hashCode());
        System.out.println(person2.hashCode());
        System.out.println("重写equals和hashcode后person1的哈希值==person3:"+person3.hashCode());

    }
    public static void main1(String[] args) {
        HashBuck hashBuck = new HashBuck();
//        hashBuck.putFront(1,1);
//        hashBuck.putFront(2,1);
//        hashBuck.putFront(3,1);
//        hashBuck.putFront(4,1);
//        hashBuck.putFront(14,11);
//        hashBuck.putFront(5,1);
//        hashBuck.putFront(6,1);
//        hashBuck.putFront(7,1);
//        hashBuck.putFront(8,1);
//        hashBuck.putFront(9,1);
//        hashBuck.putFront(10,1);

        hashBuck.putLast(1,1);
        hashBuck.putLast(2,1);
        hashBuck.putLast(3,1);
        hashBuck.putLast(4,1);
        hashBuck.putLast(14,14);
        hashBuck.putLast(5,550);
        hashBuck.putLast(6,1);
        hashBuck.putLast(7,1);
        hashBuck.putLast(8,1);
        hashBuck.putLast(9,1);
        hashBuck.putLast(10,1);
        System.out.println(hashBuck.get(5));
    }
}
